Skip to content

Fix: incorrect sorting logic (Low to High / High to Low)#33

Merged
Pragya79645 merged 1 commit intoGDSC-RCCIIT:mainfrom
mondalanshu2006-wq:fix/sorting-bug
Apr 28, 2026
Merged

Fix: incorrect sorting logic (Low to High / High to Low)#33
Pragya79645 merged 1 commit intoGDSC-RCCIIT:mainfrom
mondalanshu2006-wq:fix/sorting-bug

Conversation

@mondalanshu2006-wq
Copy link
Copy Markdown
Contributor

Issue

Sorting logic was reversed:

  • "Low to High" showed descending order
  • "High to Low" showed ascending order

Fix

Corrected comparator logic:

result.sort((a, b)  =>
    sortDirection == 'asc'
        ? a.price - b.price
        : b.price - a.price
)

### Result
- Sorting now works correctly
- UI matches expected behavior

@mondalanshu2006-wq
Copy link
Copy Markdown
Contributor Author

Hi I've fixed the sorting logic issue

"Low to High" and "High to Low" now work correctly.

please review . Happy to make further changes if needed.

Copy link
Copy Markdown
Collaborator

@Soyam27 Soyam27 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks Good!

@Pragya79645 Pragya79645 merged commit 1eb9488 into GDSC-RCCIIT:main Apr 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants